package com.tz.actions;

import com.opensymphony.xwork2.ActionSupport;
import com.tz.dao.FaqDao;
import com.tz.entity.Faq;
import com.tz.service.FaqService;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by Administrator on 16-8-5.
 */
@Namespace("/faq")
@ParentPackage("json-default")
public class FaqAction extends ActionSupport{

    private List<Faq> faqList;

    @Autowired
    FaqDao faqDao;

    public FaqAction() {
    }

    @Action(value = "faq",results = {
            @Result(type = "json",params = {"root","faqList"})
    })
    public String selectFaq(){
        faqList = faqDao.getAllFaqs();
        for (Faq f : faqList){
            System.out.println(f);
        }
        return SUCCESS;
    }

    public List<Faq> getFaqList() {
        return faqList;
    }

    public void setFaqList(List<Faq> faqList) {
        this.faqList = faqList;
    }
}
